home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-06-14 | 9.6 KB | 236 lines | [TEXT/MPS ] |
- // Experiment no.9.h
- //
- // 4/26/93 - dmh - Thrown on the grill.
- // 9/10/93 - dmh - Updated for b2.
- // - Neutralized some nasty bugs.
- // 12/18/93 - dmh - Updated for b3.
- // 3/22/94 - dmh - Updated for b4.
- // 3/24/94 - dmh - general cleanup and debugging.
- // 7/13/94 - dmh - Enabled printer resolution code.
- // 8/24/94 - dmh - Universalized.
- // 6/14/96 - cn - Updated to support Universal Interfaces 2.1.
- //
-
- #include <StdIO.h>
- #include <OSEvents.h>
- #include <AppleEvents.h>
- #include <Types.h>
- #include <Errors.h>
- #include <QuickDraw.h>
- #include <Fonts.h>
- #include <Menus.h>
- #include <Dialogs.h>
- #include <DiskInit.h>
- #include <Desk.h>
- #include <Memory.h>
- #include <Scrap.h>
- #include <Files.h>
- #include <StandardFile.h>
- #include <Resources.h>
-
- #include <Collections.h>
- #include <GXPrinterDrivers.h>
- #include <GXPrinting.h>
- #include <GXEnvironment.h>
- #include <GXGraphics.h>
- #include <FontLibrary.h>
- #include <GraphicsLibraries.h>
- #include <GXMath.h>
-
- #define kCreator 'Ex#9' /* Our registered application creator. */
- #define kMyDocCreator kCreator
- #define kMyDocType 'Doçç'
-
- #define kPrintFileType1 'tjob' /* types of print files that we look at. */
- #define kPrintFileType2 'sjob'
- #define kPrintFileType3 'rjob'
- #define kPrintFileType4 'qjob'
-
- #define kMyJobType 'TJOB' /* The type of our job resource. */
- #define kMyJobID 128 /* The ID of our job resource. */
-
- #define kMyFormatInfoType kCreator /* Type & ID of our format index collection item. */
- #define kMyFormatInfoTagID gxPrintingTagID
- #define kMyKindaCollectionType kCreator /* Type & ID of our panel settings collection item. */
- #define kMyKindaCollectionTagID gxPrintingTagID +1
-
- #define r_aboutDlog 321 /* Our "About…" dialog's resource ID. */
- #define r_msgDlog 123 /* Our message dialog's resource ID. */
- #define d_msgItem 2 /* The dialog's static text item. */
-
- #define n_dlogLevel .25 /* Level to display our dialogs at as a */
- /* percentage of the way down the */
- /* screen. (See PositionWindow.) */
-
-
- #define r_MyFormatPanelResID 6000 /* ID of our panel and panel icon resources. */
-
- #define r_printerInfoDlog 140 /* ID of our printer info dialog. */
- #define kOKButton 1 /* Our dialog's OK button item. */
-
- // MyDocumentRec - For each document we have a document job, file specification, name,
- // viewPort and a collection of pages and page formats. Note that the MyDocumentRec
- // data type in this example is simplified to handle a maximum of 20 pages.
-
- #define kMaxPages 20
-
- typedef struct MyDocumentRec {
- gxJob documentJob; // Job bound to this document.
- long numPages; // Number of pages in this document.
- long curPage; // The current page that we're looking at.
- FSSpec documentFSSpec; // The file specification for this document.
- Str31 documentTitle; // The title of this document (such
- // as "Untitled").
- WindowPtr documentWindow; // The window for this document.
- gxViewPort documentViewPort; // The viewPort used for drawing within
- // this document window.
- gxShape documentPage[kMaxPages]; // The shape data for each page.
- gxFormat pageFormat[kMaxPages]; // format for each page. If nil, we use
- // the job format. This information is not
- // used until the Optional and Advanced
- // Printing Features chapters.
- } MyDocumentRec, *MyDocumentPtr;
-
-
- typedef struct MyKindaCollectionRec {
- unsigned char isTurnedOn; // Is our panel item turned on?
- char fillByte; // C adds this if we don't (for alignment).
- short dayOfWeek; // Pop-up menu setting.
- } MyKindaCollectionRec, *MyKindaCollectionPtr, **MyKindaCollectionHdl;
-
-
- // Useful macros:
-
- #define MIN(x,y) ((x < y)? x:y)
- #define MAX(x,y) ((x > y)? x:y)
- #define ABS(x) ((x <= 0)? x:-x)
-
-
- // Other defines:
-
- #define r_menuBar 128
-
- #define mApple 128
- #define kAbout 1
-
- #define mFile 129
- #define kNew 1
- #define kOpen 2
- #define kClose 4
- #define kSave 5
- #define kSaveAs 6
- #define kInsertPage 8
- #define kDeletePage 9
- #define kDocSetup 11
- #define kPageSetup 12
- #define kPrint 13
- #define kPrintOne 14
- #define kQuit 16
-
- #define mEdit 130
- #define kUndo 1
- #define kCut 3
- #define kCopy 4
- #define kPaste 5
- #define kClear 6
-
- #define mTest 131
- #define kAheadPage 1
- #define kBackPage 2
- #define kApplyAboveFormat 3
- #define kAddForm 4
- #define kRemoveForm 5
- #define kGetCopiesInfo 6
- #define kGetFileNumPages 7
- #define kShowJobPrinterInfo 8
- #define kJobRefConTest 9
- #define kReadFilePage 10
- #define kGetPaperTypeName 11
- #define kGetPaperDimensions 12
- #define kGetAllPaperTypeInfo 13
- #define kShowPrinterResolution 15
-
- // Prototypes:
-
- OSErr MyInitializeApp(void);
- void MyAEInstallation(void);
- OSErr MyCheckAEParams(AppleEvent *theAppleEvent);
- void MyAdjustMenusForPrintDialogs(Boolean dialogGoingUp);
- void MyAdjustMenus(void);
- void MyWindowUpdate(WindowPtr whichWindow);
- OSErr MyDoEvent(EventRecord *event);
- void MyDoMenuCommand(long menuResult);
- OSErr MyFormatDialog(MyDocumentPtr myDocument);
- OSErr MyPrintDialog(MyDocumentPtr myDocument);
- OSErr MyPrintDocument(MyDocumentPtr myDocument);
- OSErr MyPrintingEventOverride(EventRecord *anEvent, Boolean filterEvent);
- OSErr MyNewDocument(Str32 docName, MyDocumentPtr myDocument);
- OSErr MyCloseDocument(MyDocumentPtr myDocument);
- OSErr MyPageFormatDialog(MyDocumentPtr myDocument);
- OSErr MyInsertPage(MyDocumentPtr myDocument);
- OSErr MyPrintDocument1(MyDocumentPtr myDocument);
- OSErr MyPrintDocument2(MyDocumentPtr myDocument);
- OSErr MyPrintDocument3(MyDocumentPtr myDocument);
- OSErr MyPrintDocument4(MyDocumentPtr myDocument);
- OSErr MyPrintOneCopy(MyDocumentPtr whichDocument);
- OSErr MyReplaceCollectionItem(void *newData, long collectSize,
- OSType collectType, long collectID,
- Collection whichCollection,
- Ptr *oldData, long *oldDataSize);
- void MyBackPage(WindowPtr whichWindow);
- void MyAheadPage(WindowPtr whichWindow);
- OSErr MySaveDocument(MyDocumentPtr myDocument, Boolean doingSaveAs);
- OSErr MySaveDocument2(MyDocumentPtr myDocument, Boolean doingSaveAs);
- OSErr MySaveJobInDataFork(MyDocumentPtr myDocument, short dataRefNum);
- OSErr MyFlattenJobProc(long dataSize, void *data, void *dataRefNum);
- OSErr MyLoadJobFromDataFork(MyDocumentPtr myDocument, short dataRefNum);
- OSErr MyUnflattenJobProc(long dataSize, void *data, void *dataRefNum);
- OSErr MyFSOpenDocument(MyDocumentPtr myDocument, FSSpec *docFSSpec);
- OSErr MyOpenDocument(MyDocumentPtr myDocument);
- OSErr MyOpenDocument2(MyDocumentPtr myDocument);
- OSErr MyPrintRecordToJob(MyDocumentPtr myDocument, THPrint hPrint);
- OSErr MyApplyPageFormat(MyDocumentPtr myDocument, gxFormat aNewFormat);
- OSErr MyDeletePage(MyDocumentPtr myDocument);
- OSErr MyAdjustFormats(MyDocumentPtr myDocument);
- OSErr MySaveFormatRefs(MyDocumentPtr myDocument);
- OSErr MyMoveFormatToJob(long oldPage, MyDocumentPtr oldDocument, long newPage, MyDocumentPtr newDocument);
- OSErr MyAddFormatForm(MyDocumentPtr myDocument);
- OSErr MyRemoveFormatForm(MyDocumentPtr myDocument);
- OSErr MyFormatDialogOverride(gxFormat aFormat, StringPtr title, gxDialogResult *result);
- OSErr MySetUpByPagePanel(gxFormat aFormat, short ourResFile);
- OSErr MyGetJobCopies(MyDocumentPtr myDocument, short *numCopies);
- OSErr MyGetPrintFilePages(FSSpec *printFSSpec, long *numCopies);
- OSErr MyShowJobPrinterInfo(MyDocumentPtr myDocument);
- OSErr MyCopyJobToDoc(MyDocumentPtr srcDocument, MyDocumentPtr destDocument);
- OSErr MyJobRefConTest(MyDocumentPtr myDocument);
- OSErr MyReadPrintFilePage(MyDocumentPtr myDocument, FSSpec *printFSSpec,
- long whichPg, gxFormat *pgFormat, gxShape *pgShape);
- OSErr MyCreatePaperType(MyDocumentPtr myDocument, Str31 paperName, gxRectangle *pageSize,
- gxRectangle *paperSize, gxPaperType *newPaperType);
- OSErr MyGetPaperTypeName(MyDocumentPtr myDocument, Str255 paperTypeName);
- OSErr MyCheckAllFormatMappings(MyDocumentPtr myDocument);
- OSErr MyGetFormatMapping(MyDocumentPtr myDocument, long whichPage,
- gxMapping *theMapping);
- OSErr MyGetPaperTypeDims(MyDocumentPtr myDocument,
- gxRectangle *pageBounds, gxRectangle *paperBounds);
- OSErr MyListAllPaperTypes(MyDocumentPtr myDocument);
- OSErr MyCreateFormatIndexList(MyDocumentPtr myDocument, Handle *theFormatIdxList);
- void MyDisplayAbout(void);
- void MyDisplayInfo(Str255 msg);
- void MyPositionWindow(WindowPtr windPtr, Boolean showIt, float vertPercent);
- void MyShowJobPrinterResolution(MyDocumentPtr myDocument);
- void MyGetFormatDeviceResolution(gxJob whichJob, Fixed *hRes, Fixed *vRes);
- void MyGetOutputDeviceResolution(gxJob whichJob, Fixed *hRes, Fixed *vRes);
- gxColorProfile MyGetFormattingPrinterProfile(MyDocumentPtr myDocument, gxColorSpace *theSpace);
- Boolean MyMakePrinterColor(MyDocumentPtr myDocument, gxColor *sourceColor, gxColor *printedColor);
- gxParsePageRangeResult MyPageRangeValidityCheck(StringPtr fromString, StringPtr toString);
- OSErr MyParsePageRangeOverride(StringPtr fromString, StringPtr toString, gxParsePageRangeResult *result);
- OSErr MyConfigurePageRange1(MyDocumentPtr myDocument);
- OSErr MyConfigurePageRange2(MyDocumentPtr myDocument);
- OSErr MyConfigurePageRange3(MyDocumentPtr myDocument);
- pascal OSErr MyHandleOAPP(AppleEvent *theAppleEvent, AppleEvent *reply, long myRefCon);
- pascal OSErr MyHandleQUIT(AppleEvent *theAppleEvent, AppleEvent *reply, long myRefCon);
- pascal OSErr MyHandleODOC(AppleEvent *theAppleEvent, AppleEvent *reply, long myRefCon);
- pascal OSErr MyHandlePDOC(AppleEvent *theAppleEvent, AppleEvent *reply, long myRefCon);
- pascal gxLoopStatus MyCheckMappingProc(gxFormat aFormat, void *theMapping);
- pascal gxLoopStatus MyPTInfoProc(gxPaperType thePaperType, void *refCon);